package com.zlyx.easy.core.entry;

import java.util.Map;
import java.util.Map.Entry;

import com.zlyx.easy.core.map.EasyMap;

/**
 * @Auth 赵光
 * @Describle 键值对存储对象
 */
public class DefaultEntry<K, V> implements Entry<K, V> {

	private K key;

	private V value;

	public DefaultEntry() {

	}

	public DefaultEntry(K key) {
		this(key, null);
	}

	public DefaultEntry(K key, V value) {
		this.key = key;
		this.value = value;
	}

	@Override
	public K getKey() {
		return key;
	}

	public void setKey(K key) {
		this.key = key;
	}

	@Override
	public V getValue() {
		return value;
	}

	@Override
	public V setValue(V value) {
		V tValue = value;
		this.value = value;
		return tValue;
	}

	public DefaultEntry<K, V> setValue(K key, V value) {
		this.key = key;
		this.value = value;
		return this;
	}

	public Map<K, V> toMap() {
		return EasyMap.newMap(key, value);
	}
}
